package org.wyn.mongodb.bean;

import org.wyn.common.Table;
import org.wyn.mongodb.dao.impl.UserDao;
import org.wyn.util.CodeMD5;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import com.google.code.morphia.annotations.Indexed;
import com.google.code.morphia.utils.IndexDirection;

/**
 * 用户信息实体类
 * @author wyn
 *
 */
@Entity(value = Table.CollectionName.USER, noClassnameStored = true)
public class User extends Info {

	
	/**
	 * 用户名
	 */
	@Id
	@Indexed(value = IndexDirection.ASC)
	private String userName;
	/**
	 * 密码
	 */
	private String password;
	/**
	 * 真实姓名
	 */
	private String realName;
	/**
	 * 性别:男=male 女=female
	 */
	private String gender;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		//加密，这样数据库中存放的是加密后的密码
		this.password = CodeMD5.MD5_Code(password);
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public String getGender() {
		return gender;
	}
	public void setGender(String gender) {
		this.gender = gender;
	}
	public static void main(String[] args) {
		UserDao dao = new UserDao();
		User user = new User();
		user.setAddTime(System.currentTimeMillis());
		user.setUpdateTime(System.currentTimeMillis());
		user.setUserName("123");
		user.setPassword(CodeMD5.MD5_Code("123456"));
		dao.save(user);
	}
}
